package com.irdstudio.efp.batch.service.boot;

import com.irdstudio.efp.batch.service.domain.TxtFileLoadBean;
import com.irdstudio.efp.batch.service.domain.TxtFleLoandDemoBean;
import com.irdstudio.efp.batch.service.util.DueDataPlugin;
import com.irdstudio.efp.batch.service.util.DueDataTaskThread;

import java.io.File;
import java.io.FileOutputStream;
import java.util.List;

/**
 * 开发人员：chenxuan
 * 创建日期：2019/5/29 11:15
 * 功能描述：数据加工测试DEMO
 *
 * @version 0.1
 */
public class DueDataPluginTest extends DueDataTaskThread {
    @Override
    public void run() {
        try {
            List<TxtFileLoadBean> txtFileLoadBeans = this.txtFileLoadBeans;
            String threadName = Thread.currentThread().getName();
            System.out.println("数据验证"+txtFileLoadBeans.get(0).toString());
            byte[] bytes1 = (txtFileLoadBeans.get(0).toString()+threadName).getBytes();
            String path = "D:\\var\\" + threadName + ".txt";
            File file = new File(path);
            if (!file.exists()) {
                File dir = new File(file.getParent());
                dir.mkdirs();
                file.createNewFile();
            }
            FileOutputStream outputStream = new FileOutputStream(file);
            outputStream.write(bytes1);
            outputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            countDownLatch.countDown();
        }

    }

    public static void main(String[] args) {
        DueDataPlugin dueDataPlugin = new DueDataPlugin("E:\\s000_ag_agt_imp_dt_h_f.20130619.dat", "\u0002", "UTF-8", 2, 100000, 3, new TxtFleLoandDemoBean(), new DueDataPluginTest());
        dueDataPlugin.doTask();
    }
    @Override
    public DueDataPluginTest clone() throws CloneNotSupportedException {
        return new DueDataPluginTest();
    }
}
